using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class LogTEST : MonoBehaviour {
    string  message="";
    public Text text;//UGUI的一个文本
    // Use this for initialization
    void Start () {
        //在一个日志信息上注册一个委托来被调用
        Application.RegisterLogCallback (MyLogCallback);
    }

    // Update is called once per frame
    void Update () {
        text.text = message;
    }

    /// <summary>
    /// log callback check
    /// </summary>
    /// <param name="condition">log内容.</param>
    /// <param name="stackTrace">log产生的栈数据追踪</param>
    /// <param name="type">log的类型.</param>
    void  MyLogCallback (string condition, string stackTrace, LogType type){
        switch(type){
        case LogType.Assert:
            message += "      receive an assert log"+",condition="+condition+",stackTrace="+stackTrace;
            break;
        case LogType.Error:
            message += "      receive an Error log"+",condition="+condition+",stackTrace="+stackTrace;
            break;
        case LogType.Exception:
            message += "      receive an Exception log"+",condition="+condition+",stackTrace="+stackTrace;
            break;
        case LogType.Log:
            message += "      receive an Log log"+",condition="+condition+",stackTrace="+stackTrace;
            break;
        case LogType.Warning:
            message += "      receive an Warning log"+",condition="+condition+",stackTrace="+stackTrace;
            break;



        }

    }

    void OnGUI(){

        if(GUI.Button(new Rect(10,20,200,40),"assert")){
            Debug.LogAssertion ("assertion");
        }else if(GUI.Button(new Rect(10,80,200,40),"error")){
            Debug.LogError ("error");
        }else if(GUI.Button(new Rect(10,140,200,40),"exception")){

            Debug.LogException (new System.NullReferenceException());
        }else if(GUI.Button(new Rect(10,200,200,40),"log")){
            Debug.Log ("log");
        }else if(GUI.Button(new Rect(10,260,200,40),"warning")){
            Debug.LogWarning ("waring");
        }
    }
}